﻿using System.Collections;
using UnityEngine;
using XLua_Ki;

public class Hotfix_NormalClass_Demo : MonoBehaviour {

    void Start()
    {
        string mainABRoot = Application.dataPath + @"\XLua\MiniKimmy\Examples\03_Hotfix\streamingassets\MiniKimmy_Hotfix_NormalClass\";
        
        GameObject obj = new GameObject("MiniKimmy");
        obj.AddComponent<GameManager_Ki>();
        DontDestroyOnLoad(obj);

        StartCoroutine(TestHotFix(mainABRoot));  
    }

    IEnumerator TestHotFix(string mainABRoot)
    {
        GameManager_Ki.Instance.GetResourcesManager_Ki().LoadALLABPrefabs(mainABRoot);   //启动热更新.(注释掉就是原始c#逻辑)

        Debug.Log("MiniKimmy : wait for 3s ...");
        int wait = 0;
        while (wait < 3)
        {
            wait++;
            Debug.Log("MiniKimmy :" + (3 - wait) + "...");
            yield return new WaitForSeconds(1f);
        }

        yield return null;
        Hotfix_NomalClass_Test MyClass = new Hotfix_NomalClass_Test(5);
        MyClass.MyMethod();
        Hotfix_NomalClass_Test.Pow(MyClass.Num,3);
    }
}
